--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>添加商品</title>

</head>
<body>
<div class="row">
    <div class="col-md-12">
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title">
            商品管理
            <small>商品添加</small>
        </h3>
        <ul class="page-breadcrumb breadcrumb">
            <li>
                <i class="fa fa-home"></i>
                <a href="${ctx}/main">
                    首页
                </a>
                <i class="fa fa-angle-right"></i>
            </li>
            <li>
                <a href="${ctx}/product/product_list">
                    商品管理
                </a>
                <i class="fa fa-angle-right"></i>
            </li>
            <li>
                <a href="#">
                    商品添加
                </a>
            </li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB-->
    </div>
</div>
<!-- END PAGE HEADER-->
<!------内容区---->
<div class="main">

    <div class="row">
        <div class="col-md-12">
            <form:form modelAttribute="PProductModel" method="post"
                       class="form-horizontal">
                <div class="form-group">
                    <label class="control-label col-md-3">LOGO：</label>

                    <div class="col-md-4">
                        <div class="input-group">
                            <img alt="" id="aimg" src="${ctx}/assets/img/upload_img.png" width="100px" height="100px"/>
                            <form:hidden path="productMainImage" id="product_pic"/>
                            <input id="image3" type="button" value="上传图片" style="display: none"/>

                        </div>

                        <form:errors path="productMainImage" cssClass="field-validation-error" element="div"></form:errors>
                    </div>

                </div>

                <div class="form-group">
                    <label class="control-label col-md-3">商品名称：</label>

                    <div class="col-md-4">
                        <form:input path="productName" cssClass="form-control"  placeholder="商品名称"></form:input>
                    </div>
                    <form:errors path="productName" cssClass="field-validation-error" element="div"></form:errors>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">金额：(每件商品价格)</label>
                    <div class="col-md-2">
                        <div class="input-group">
                            <form:input path="salePrice" cssClass="form-control" type="number"  placeholder="金额"></form:input>
                            <span class="input-group-addon">元</span>
                        </div>
                        <form:errors path="salePrice" cssClass="field-validation-error" element="div"></form:errors>
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-md-3">产品简介：</label>

                    <div class="col-md-8">
                        <form:textarea path="productDescription" cssClass="form-control" cssStyle="width: 100%; height: 400px;" cols="10" rows="3"></form:textarea>
                    </div>
                    <form:errors path="productDescription" cssClass="field-validation-error" element="div"></form:errors>
                </div>
                <div class="form-group">
                    <div class="col-md-9 col-md-offset-3">
                        <button type="submit" class="btn blue">添加商品</button>
                        <span class="field-validation-error">${error}</span>
                    </div>
                </div>
            </form:form>
        </div>
    </div>

</div>
<myfooter>
<style>
    .ke-upload-area input .ke-upload-file {
        background: url("/assets/img/upload_img.png");
        background-size: 100% 100%;
        height: 80px;
        width: 100px;
        display: block;
        border: none;;;
        top: 0px;
    }
</style>
<script>
    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('textarea[name="productDescription"]', {
            allowFileManager: true,
            uploadJson: '${ctx}/file_upload?dir=image'
        });
        K('#aimg').click(function () {
            editor.loadPlugin('image', function () {
                editor.plugin.imageDialog({
                    showRemote: false,
                    imageUrl: K('#product_pic').val(),
                    clickFn: function (url, title, width, height, border, align) {
                        K('#product_pic').val(url);
                        K('#aimg').attr("src", url);
                        editor.hideDialog();
                    }
                });
            });
        });


        /*var uploadbutton = K.uploadbutton({
         button : K('#image3')[0],
         fieldName : 'imgFile',
         url : '
        ${ctx}/file_upload?dir=image',
         afterUpload : function(data) {
         if (data.error === 0) {
         var url = K.formatUrl(data.url, 'absolute');

         K('#aimg').attr("src", url);
         K('#product_pic').val(url);
         } else {
         alert(data.message);
         }
         },
         afterError : function(str) {
         alert('自定义错误信息: ' + str);
         }
         });
         uploadbutton.fileBox.change(function(e) {
         uploadbutton.submit();
         });*/
    });
</script>
    </myfooter>
</body>
</html>